package com.ruoyi.web.controller.ddsystem;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DdOrderInfo;
import com.ruoyi.system.service.IDdOrderInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 进行中订单Controller
 * 
 * @author Abeiv
 * @date 2020-03-20
 */
@Controller
@RequestMapping("/system/order_rider_info")
public class DdOrderInfoController extends BaseController
{
    private String prefix = "system/order_rider_info";

    @Autowired
    private IDdOrderInfoService ddOrderInfoService;

    @RequiresPermissions("system:order_rider_info:view")
    @GetMapping()
    public String order_rider_info(String oid, Model m)
    {
        m.addAttribute("oid",oid);
        return prefix + "/order_rider_info";
    }

    /**
     * 查询进行中订单列表
     */
    @RequiresPermissions("system:order_rider_info:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(DdOrderInfo ddOrderInfo)
    {
        startPage();
        List<DdOrderInfo> list = ddOrderInfoService.selectDdOrderInfoList(ddOrderInfo);
        return getDataTable(list);
    }

    /**
     * 导出进行中订单列表
     */
    @RequiresPermissions("system:order_rider_info:export")
    @Log(title = "进行中订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(DdOrderInfo ddOrderInfo)
    {
        List<DdOrderInfo> list = ddOrderInfoService.selectDdOrderInfoList(ddOrderInfo);
        ExcelUtil<DdOrderInfo> util = new ExcelUtil<DdOrderInfo>(DdOrderInfo.class);
        return util.exportExcel(list, "order_rider_info");
    }

    /**
     * 新增进行中订单
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存进行中订单
     */
    @RequiresPermissions("system:order_rider_info:add")
    @Log(title = "进行中订单", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(DdOrderInfo ddOrderInfo)
    {
        return toAjax(ddOrderInfoService.insertDdOrderInfo(ddOrderInfo));
    }

    /**
     * 修改进行中订单
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        DdOrderInfo ddOrderInfo = ddOrderInfoService.selectDdOrderInfoById(id);
        mmap.put("ddOrderInfo", ddOrderInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存进行中订单
     */
    @RequiresPermissions("system:order_rider_info:edit")
    @Log(title = "进行中订单", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(DdOrderInfo ddOrderInfo)
    {
        return toAjax(ddOrderInfoService.updateDdOrderInfo(ddOrderInfo));
    }

    /**
     * 删除进行中订单
     */
    @RequiresPermissions("system:order_rider_info:remove")
    @Log(title = "进行中订单", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(ddOrderInfoService.deleteDdOrderInfoByIds(ids));
    }
}
